package com.thf.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {


    @Bean
    public Queue thfQueue() {
        System.out.println("thfQueue对象实例化");
        return new Queue("thfQueue",true);
    }

    @Bean
    public Queue taskQueue() {
        System.out.println("taskQueue对象实例化");
        return new Queue("taskQueue",true);
    }
    @Bean
    TopicExchange thfTopicExchange() {
        return new TopicExchange("thfTopicExchange",true,false);
    }


    @Bean
    Binding thfQueueTothfTopic() {
        return BindingBuilder.bind(thfQueue()).to(thfTopicExchange()).with("thf.*");
    }

    @Bean
    Binding taskQueueTothfTopic() {
        return BindingBuilder.bind(taskQueue()).to(thfTopicExchange()).with("task.*");
    }

}